/*
 * $Id: string_fill.c,v 1.1 2005-12-11 14:53:03 bacon Exp $
 */

#if defined(__MSTRING)
#include <xp/bas/mstring.h>
#elif defined(__WSTRING)
#include <xp/bas/mstring.h>
#else
#include <xp/bas/string.h>
#endif

#include <xp/bas/assert.h>

xp_size_t xp_strset (xp_char_t* buf, xp_char_t c, xp_size_t n)
{
	xp_size_t len = n;
	buf[n] = XP_CHAR('\0');
	while (n > 0) buf[--n] = c;
	return len;
}

xp_size_t xp_strxset (xp_char_t* buf, xp_size_t bsz, xp_char_t c, xp_size_t n)
{
	xp_size_t len;

	xp_assert (bsz > 0);
	if (n >= bsz) n = bsz - 1;
	len = n;

	buf[n] = XP_CHAR('\0');
	while (n > 0) buf[--n] = c;
	return len;
}
